<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <title>消息模版</title>
    <meta name="decorator" content="default"/>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#value").focus();
            $("#inputForm").validate({
                submitHandler: function (form) {
                    loading('正在提交，请稍等...');
                    form.submit();
                },
                errorContainer: "#messageBox",
                errorPlacement: function (error, element) {
                    $("#messageBox").text("输入有误，请先更正。");
                    if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
                        error.appendTo(element.parent().parent());
                    } else {
                        error.insertAfter(element);
                    }
                }
            });
        });
        $(function(){
            var flagtype=0;
            $("#type").change(function() {
                flagtype=$(this).val();
            });
            $("#typeButton").click(function(){
                top.$.jBox.open("iframe:${ctx}/business/messagetemplate/select?type="+flagtype, "选择消息模版", 800, 540, {
                    buttons:{"确定":"ok", "关闭":true}, submit:function(v, h, f){
                        if (v=="ok"){
                            var page = h.find("iframe")[0].contentWindow;
                            var ids = page.$('input:radio[name="id"]:checked').val();//id
                            var names = page.$('input:radio[name="id"]:checked').attr("text");//name
                            var editable=page.$('input:radio[name="id"]:checked').attr("editable");//是否可编辑 0不可编辑  1可编辑
                            if (ids == ''){
                                top.$.jBox.tip("您未选择任何数据。");
                                return false;
                            }
                            $("#messagetemplateId").val(ids);
                            $("#messagetemplateName").val(names);
                            $.ajax({
                                async: false,
                                url: "${ctx}/business/messagetemplate/getContentById?id="+ids,
                                type: "POST",
                                success:function(data){
                                    $("#templateContent").val(data);
                                }
                            })
                            if (editable=="0") $("#templateContent").attr("readonly","readonly");//是否允许修改 0:否，1:是
                            else  $("#templateContent").removeAttr("readonly");
                        }//
                    }, loaded:function(h){
                        $(".jbox-content", top.document).css("overflow-y","hidden");
                    }
                });
            });
        });
        function submk(){
            $("#form1").submit();
        }
    </script>
</head>
<body>
<br/>
<form:form id="form1" modelAttribute="messageTemplate" action="${ctx}/business/messagetemplate/sendmsgbycamporclass" method="post" class="form-horizontal"  target="mainFrame">
    <form:hidden path="id"/>
    <input type="hidden" name="returnUrl" value="${returnUrl}">
    <input type="hidden" name="classroomId" value="${classroomId}">
    <input type="hidden" name="campperiodId" value="${campperiodId}">
    <tags:message content="${message}"/>
    <div class="control-group">
        <label class="control-label">选择消息通知方式:</label>
        <div class="controls">
            <form:select path="type" name="type" class="input-medium required">
                <form:options items="${dic:getBusDictList('tb_message_template_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
            </form:select>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>

    <div class="control-group">
        <label class="control-label">选择模版:</label>
        <div class="controls">
            <div class="input-append">
                <input id="messagetemplateId" name="messagetemplateId" class="required" type="hidden" value="" aria-required="true">
                <input id="messagetemplateName" name="messagetemplateName" readonly="readonly" type="text" value="" maxlength="50" class="required" style="" aria-required="true"><a id="typeButton" href="javascript:" class="btn " style="_padding-top:6px;">&nbsp;<i class="icon-search"></i>&nbsp;</a>&nbsp;&nbsp;
            </div>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>

    <div class="control-group">
        <label class="control-label">模板内容:</label>
        <div class="controls">
            <form:textarea path="templateContent" htmlEscape="false" rows="5" maxlength="200" class="required input-xlarge"/>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">目标人群:</label>
        <div class="controls">
          ${target}
        </div>
    </div>
</form:form>
</body>
</html>